package com.biz.primus.base.vo;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.io.Serializable;
import lombok.Data;
import org.springframework.data.domain.PageRequest;

/**
 * @author yanweijin
 * @date 2017/9/14
 */
@Data
@ApiModel(description = "基础分页对象")
public class PageVo implements Serializable {

    private static final long serialVersionUID = -2138486238199051448L;

    @ApiModelProperty("分页参数:要加载的页面,第一页为1,不传时默认值为1")
    private int page = 1;

    @ApiModelProperty("分页参数:每页记录数,不传时默认值为50")
    private int size = 50;

    public PageRequest toPageRequest() {
        page = Math.max(page, 1);
        return new PageRequest(page - 1, size);
    }


}
